//
//  AppIdentifier.m
//  base
//
//  Created by Demi on 23/05/2017.
//  Copyright © 2017 Azazie. All rights reserved.
//

#import "AppIdentifier.h"
#import <AdSupport/AdSupport.h>
#import <UIKit/UIKit.h>
#import <AppTrackingTransparency/AppTrackingTransparency.h>

@implementation AppIdentifier

+ (NSString *)IDFA
{
    __block NSString *cid = @"";
    if (@available(iOS 14, *)){
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                NSString *idfaString = [[ASIdentifierManager sharedManager] advertisingIdentifier].UUIDString;
                cid = idfaString?:@"";
            }
        }];
    } else {
        NSUUID *UUID = [ASIdentifierManager sharedManager].advertisingIdentifier;
        cid = UUID ? UUID.UUIDString : @"";
    }
    return cid;
}

+ (NSString *)IDFV
{
    NSUUID *UUID = [[UIDevice currentDevice] identifierForVendor];
    return UUID ? UUID.UUIDString : @"";
}

@end
